package com.sands.network.api;


import com.sands.network.module.ObjResponse;

import java.util.Map;

import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.Url;
import rx.Observable;

/**
 * Created by Administrator on 2017/7/3.
 */

//上传多张图片
// MultipartBody.Part  和后端约定好Key，这里的partName是用image

/**
 * // MultipartBody.Part  和后端约定好Key，这里的partName是用image
 * MultipartBody.Part body =
 * MultipartBody.Part.createFormData("image", file.getName(), requestFile);
 * url 是上传路径
 */
public interface BaseUpdataServiceApi {
    @Multipart
    @POST()
   Observable<ObjResponse<Object>> baseUpdataServiceApis
            (@Url String url, @PartMap() Map<String, RequestBody> maps);



    /**
     * 单独上传一张图片
     * @param url
     * @param file
     * @return
     */
    @Multipart
    @POST()
    Observable<ObjResponse<Object>> baseUpdataServiceApi(
            @Url() String url,
            @Part MultipartBody.Part file);


    /**
     * 完美解决你想用表单一起将文字和图片一起提交的情况
     *
     *  //构建body
     RequestBody requestBody = new MultipartBody.Builder().setType(MultipartBody.FORM)
     .addFormDataPart("name", name)
     .addFormDataPart("psd", psd)
     .addFormDataPart("file", file.getName(), RequestBody.create(MediaType.parse("image/*"), file))
     .build();
     * @param url
     * @param Body
     * @return
     */
    @POST()
    Observable<ObjResponse<Object>> baseUpdataBodyServiceApi(
            @Url() String url,
            @Body RequestBody Body);
}
